# 学生类
class Student:
    def __init__(self, student_id, name, age):
        self.student_id = student_id
        self.name = name
        self.age = age

    def __str__(self):
        return f"学号: {self.student_id}, 姓名: {self.name}, 年龄: {self.age}"

# 学生管理器类
class StudentManager:
    def __init__(self):
        self.students = []

    def add_student(self, student):
        self.students.append(student)
        print("学生添加成功！")

    def query_student(self, student_id):
        for student in self.students:
            if student.student_id == student_id:
                return student
        return None

    def display_students(self):
        if not self.students:
            print("学生列表为空！")
        else:
            for student in self.students:
                print(student)

    def delete_student(self, student_id):
        for student in self.students:
            if student.student_id == student_id:
                self.students.remove(student)
                print("学生删除成功！")
                return
        print("未找到该学生！")

# 主函数
def main():
    student_manager = StudentManager()

    while True:
        print("\n欢迎使用学生信息管理系统")
        print("1. 添加学生")
        print("2. 查询学生")
        print("3. 查看学生列表")
        print("4. 删除学生")
        print("5. 退出程序")
        option = input("请输入数字选择功能: ")

        if option == "1":
            print("执行添加学生")
            student_id = input("请输入学号: ")
            name = input("请输入姓名: ")
            age = input("请输入年龄: ")
            student = Student(student_id, name, age)
            student_manager.add_student(student)

        elif option == "2":
            print("执行查询学生")
            student_id = input("请输入要查询的学生学号: ")
            student = student_manager.query_student(student_id)
            if student:
                print(student)
            else:
                print("未找到该学生！")

        elif option == "3":
            print("执行查看列表")
            student_manager.display_students()

        elif option == "4":
            print("执行删除学生")
            student_id = input("请输入要删除的学生学号: ")
            student_manager.delete_student(student_id)

        elif option == "5":
            print("执行退出程序")
            break

        else:
            print("无效输入，请重新选择！")

# 测试用例
if __name__ == "__main__":
    main()